<template>
  <div class="car-container">
    <!-- 头部banner -->
    <div class="car-banner">
      <div class="banner-content">
        <h1 class="banner-title">汽车世界 - 探索无限可能</h1>
        <p class="banner-subtitle">了解最新汽车品牌、详细测评和技术参数</p>
      </div>
    </div>

    <!-- 内容分类标签 -->
    <div class="car-categories">
      <button 
        v-for="category in categories" 
        :key="category.id"
        class="category-tab"
        :class="{ active: activeCategory === category.id }"
        @click="activeCategory = category.id"
      >
        {{ category.name }}
      </button>
    </div>

    <!-- 热门品牌区域 -->
    <div class="popular-brands-section">
      <div class="section-header">
        <h2>热门汽车品牌</h2>
        <a href="#" class="more-link">查看更多 <i class="fa fa-angle-right"></i></a>
      </div>
      <div class="brands-grid">
        <div 
          v-for="brand in popularBrands" 
          :key="brand.id"
          class="brand-card"
          @click="selectBrand(brand)"
        >
          <img :src="brand.logo" :alt="brand.name" class="brand-logo">
          <h3 class="brand-name">{{ brand.name }}</h3>
          <p class="brand-desc">{{ brand.description }}</p>
        </div>
      </div>
    </div>

    <!-- 精选测评区域 -->
    <div class="featured-reviews-section">
      <div class="section-header">
        <h2>精选测评</h2>
        <a href="#" class="more-link">查看更多 <i class="fa fa-angle-right"></i></a>
      </div>
      <div class="reviews-grid">
        <div 
          v-for="review in featuredReviews" 
          :key="review.id"
          class="review-card"
        >
          <img :src="review.thumbnail" :alt="review.title" class="review-thumbnail">
          <div class="review-info">
            <h3 class="review-title">{{ review.title }}</h3>
            <div class="review-meta">
              <span class="review-author">{{ review.author }}</span>
              <span class="review-date">{{ review.date }}</span>
            </div>
            <div class="review-score">
              <span class="score-label">综合评分：</span>
              <span class="score-value">{{ review.score }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 汽车参数展示 -->
    <div class="car-params-section">
      <div class="section-header">
        <h2>热门车型参数</h2>
      </div>
      <div class="params-table">
        <table>
          <thead>
            <tr>
              <th>车型名称</th>
              <th>品牌</th>
              <th>价格区间</th>
              <th>动力系统</th>
              <th>百公里加速</th>
              <th>最高时速</th>
              <th>综合油耗</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="car in popularCars" :key="car.id">
              <td>{{ car.name }}</td>
              <td>{{ car.brand }}</td>
              <td>{{ car.price }}</td>
              <td>{{ car.engine }}</td>
              <td>{{ car.acceleration }}</td>
              <td>{{ car.topSpeed }}</td>
              <td>{{ car.fuelConsumption }}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>

    <!-- 最新资讯区域 -->
    <div class="car-news-section">
      <div class="section-header">
        <h2>汽车行业最新资讯</h2>
      </div>
      <div class="news-grid">
        <div 
          v-for="news in latestNews" 
          :key="news.id"
          class="news-card"
        >
          <img :src="news.image" :alt="news.title" class="news-image">
          <h3 class="news-title">{{ news.title }}</h3>
          <p class="news-summary">{{ news.summary }}</p>
          <span class="news-date">{{ news.date }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import logoImage from '@/assets/logo.png'

export default {
  name: 'CarView',
  data() {
    return {
      // 分类数据
      categories: [
        { id: 'all', name: '全部' },
        { id: 'sedan', name: '轿车' },
        { id: 'suv', name: 'SUV' },
        { id: 'mpv', name: 'MPV' },
        { id: 'electric', name: '电动车' },
        { id: 'luxury', name: '豪华车' },
        { id: 'sports', name: '跑车' },
      ],
      activeCategory: 'all',
      
      // 热门汽车品牌
      popularBrands: [
        {
          id: 1,
          name: '奔驰',
          logo: logoImage,
          description: '德国豪华汽车品牌',
        },
        {
          id: 2,
          name: '宝马',
          logo: logoImage,
          description: '德国高端汽车制造商',
        },
        {
          id: 3,
          name: '奥迪',
          logo: logoImage,
          description: '德国豪华汽车品牌',
        },
        {
          id: 4,
          name: '特斯拉',
          logo: logoImage,
          description: '美国电动汽车公司',
        },
        {
          id: 5,
          name: '比亚迪',
          logo: logoImage,
          description: '中国新能源汽车领导者',
        },
        {
          id: 6,
          name: '丰田',
          logo: logoImage,
          description: '日本汽车制造商',
        },
      ],
      
      // 精选测评
      featuredReviews: [
        {
          id: 1,
          title: '深度测评：比亚迪汉EV 2024款 - 国产电动车的标杆之作',
          thumbnail: logoImage,
          author: '汽车评测师小李',
          date: '2024-01-15',
          score: 9.2,
        },
        {
          id: 2,
          title: '奔驰E级与宝马5系对比测评 - 豪华行政级轿车的巅峰对决',
          thumbnail: logoImage,
          author: '豪华车评测中心',
          date: '2024-01-10',
          score: 8.9,
        },
        {
          id: 3,
          title: '特斯拉Model Y Performance版赛道测试 - 性能与实用的完美结合',
          thumbnail: logoImage,
          author: '新能源汽车网',
          date: '2024-01-08',
          score: 9.5,
        },
      ],
      
      // 热门车型参数
      popularCars: [
        {
          id: 1,
          name: '比亚迪汉EV',
          brand: '比亚迪',
          price: '21.98-32.98万',
          engine: '纯电动',
          acceleration: '3.9秒',
          topSpeed: '200km/h',
          fuelConsumption: '13.5kWh/100km',
        },
        {
          id: 2,
          name: '奔驰E级',
          brand: '奔驰',
          price: '43.08-54.88万',
          engine: '2.0T/3.0T',
          acceleration: '5.9秒',
          topSpeed: '250km/h',
          fuelConsumption: '7.8L/100km',
        },
        {
          id: 3,
          name: '宝马5系',
          brand: '宝马',
          price: '43.39-65.99万',
          engine: '2.0T/3.0T',
          acceleration: '5.6秒',
          topSpeed: '250km/h',
          fuelConsumption: '7.6L/100km',
        },
        {
          id: 4,
          name: '特斯拉Model Y',
          brand: '特斯拉',
          price: '26.39-36.39万',
          engine: '纯电动',
          acceleration: '3.7秒',
          topSpeed: '250km/h',
          fuelConsumption: '14.8kWh/100km',
        },
      ],
      
      // 最新资讯
      latestNews: [
        {
          id: 1,
          title: '比亚迪2024年销量目标公布，计划突破400万辆',
          image: logoImage,
          summary: '比亚迪汽车近日公布了2024年的销量目标，计划全年销量突破400万辆，继续领跑全球新能源汽车市场。',
          date: '2024-01-20',
        },
        {
          id: 2,
          title: '奔驰全新EQG概念车发布，纯电版大G即将量产',
          image: logoImage,
          summary: '奔驰在CES 2024上发布了全新EQG概念车，这标志着经典的G级越野车即将迎来纯电动版本。',
          date: '2024-01-18',
        },
        {
          id: 3,
          title: '国产Model 3改款版将于下月上市，续航提升10%',
          image: logoImage,
          summary: '特斯拉上海工厂透露，改款后的国产Model 3将于下个月正式上市，续航里程相比现款提升约10%。',
          date: '2024-01-16',
        },
      ],
    }
  },
  methods: {
    // 选择品牌
    selectBrand(brand) {
      console.log('选择品牌:', brand.name)
      // 实际应用中可以跳转到品牌详情页
    },
    
    // 查看完整测评
    viewFullReview(review) {
      console.log('查看测评:', review.title)
      // 实际应用中可以跳转到测评详情页
    },
    
    // 查看车型详情
    viewCarDetails(car) {
      console.log('查看车型:', car.name)
      // 实际应用中可以跳转到车型详情页
    },
  },
}
</script>

<style scoped>
/* 汽车页面容器 */
.car-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 50px;
}

/* 头部banner */
.car-banner {
  position: relative;
  height: 400px;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-content {
  text-align: center;
  color: white;
  z-index: 1;
}

.banner-title {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 16px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.banner-subtitle {
  font-size: 20px;
  opacity: 0.9;
}

/* 分类标签 */
.car-categories {
  background-color: white;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  white-space: nowrap;
}

.category-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  border-radius: 16px;
  transition: all 0.3s ease;
}

.category-tab:hover {
  color: #1e3c72;
}

.category-tab.active {
  color: white;
  background-color: #1e3c72;
}

/* 通用区域样式 */
.popular-brands-section,
.featured-reviews-section,
.car-params-section,
.car-news-section {
  margin: 30px 20px;
  background-color: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
}

.section-header h2 {
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

.more-link {
  color: #1e3c72;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.more-link:hover {
  text-decoration: underline;
}

/* 品牌网格 */
.brands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.brand-card {
  background-color: #fafafa;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid #e0e0e0;
}

.brand-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.brand-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 12px;
}

.brand-name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
}

.brand-desc {
  font-size: 14px;
  color: #666;
}

/* 测评网格 */
.reviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 24px;
}

.review-card {
  display: flex;
  gap: 16px;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fafafa;
  transition: all 0.3s ease;
  cursor: pointer;
}

.review-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.review-thumbnail {
  width: 180px;
  height: 120px;
  object-fit: cover;
}

.review-info {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.review-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
  line-height: 1.4;
}

.review-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
}

.review-score {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-label {
  font-size: 14px;
  color: #666;
}

.score-value {
  font-size: 20px;
  font-weight: bold;
  color: #e74c3c;
}

/* 参数表格 */
.params-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

th {
  background-color: #f5f5f5;
  font-weight: bold;
  color: #333;
}

tr:hover {
  background-color: #fafafa;
}

/* 资讯网格 */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.news-card {
  border-radius: 8px;
  overflow: hidden;
  background-color: #fafafa;
  transition: all 0.3s ease;
  cursor: pointer;
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.news-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.news-title {
  font-size: 18px;
  font-weight: bold;
  margin: 16px 16px 8px 16px;
  color: #333;
  line-height: 1.4;
}

.news-summary {
  font-size: 14px;
  color: #666;
  margin: 0 16px 12px 16px;
  line-height: 1.5;
}

.news-date {
  font-size: 12px;
  color: #999;
  margin: 0 16px 16px 16px;
  display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .banner-title {
    font-size: 36px;
  }
  
  .banner-subtitle {
    font-size: 16px;
  }
  
  .reviews-grid {
    grid-template-columns: 1fr;
  }
  
  .review-card {
    flex-direction: column;
  }
  
  .review-thumbnail {
    width: 100%;
    height: 200px;
  }
  
  .brands-grid,
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .banner-title {
    font-size: 28px;
  }
  
  .brands-grid,
  .news-grid {
    grid-template-columns: 1fr;
  }
  
  .car-categories {
    padding: 12px;
    gap: 8px;
  }
  
  .category-tab {
    padding: 6px 12px;
    font-size: 14px;
  }
}
</style>